﻿	<%@ taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core'%>
	<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
	
	<script type="text/javascript">
		var newGoodsUnitCallback = function () 
		{
			$('#dlg-goodsUnit #fm-goodsUnit #name').focus();
			$('#dlg-buttons-goodsUnit #save-goodsUnit-add').css('visibility', 'visible');
		}
		
		var goodsUnitStyler = function (value,row,index) 
		{
			return "<a href='javascript:void(0)' onclick='editGoodsUnit("+row.id+")' style='text-decoration: underline'>编辑</a>&nbsp;<a href='javascript:void(0)' onclick='delGoodsUnit(" +row.id + ")' style='text-decoration: underline'>删除</a>";
		}
		
		var editGoodsUnit = function(rowId) 
		{
			//$('#toolbar-goodsUnit #btn-editGoodsUnit').click ();
			$('#dlg-buttons-goodsUnit #save-goodsUnit-add').css('visibility', 'hidden');
			$('#dg-goodsUnit').datagrid('selectRecord', rowId);
			var row = $('#dg-goodsUnit').datagrid('getSelected');
			$('#dlg-goodsUnit form').form('clear');
			if (row) {
				$('#dlg-goodsUnit').dialog('open').dialog('setTitle', '编辑货物单位');
				$('#dlg-goodsUnit form').form('load', row);
				saveOrEditUrl = '<c:url value='/goodsUnit/updateModel.html' />';
				$('#dlg-goodsUnit #fm-goodsUnit #name').focus();
			}
		}
		
		var delGoodsUnit = function (id) 
		{
			$.messager.confirm('确认',
				'您确认要删除这个 ' + '货物单位' + ' 吗?', function(r) {
					if (r) {
						ajaxPostRequest ('<c:url value='/goodsUnit/deleteModels.html' />', {ids:id}, function() {$('#dg-goodsUnit').datagrid('reload');});
					}
				});
		}
		
	</script>
	
	<div style="width:500px; ">
		<table id="dg-goodsUnit" title="<spring:message code="goodsUnitManagement" />" class="easyui-datagrid"
			style="height:400px;" url="<c:url value='/goodsUnit/getAllModel.html' />"
			toolbar="#toolbar-goodsUnit" pagination="false" rownumbers="true" 
			 singleSelect="true" checkOnSelect="true" selectOnCheck="false"
			data-options="fitColumns:true, idField:'id'">
			<thead>
				<tr>
					<!-- <th data-options="field:'ck',checkbox:true"></th> -->
					<th field="id" hidden="true"><spring:message code="id" /></th>
					<th field="name" width="30" sortable="true"><spring:message code="name" /></th>
					<th field="action" width="50" data-options="formatter:goodsUnitStyler"><spring:message code="action" /></th>
				</tr>
			</thead>
		</table>
	</div>
	
	<div id="toolbar-goodsUnit">
		<a href="javascript:void(0)" class="easyui-linkbutton" 
			iconCls="icon-add" plain="true" onclick="newModel('#dlg-goodsUnit', '<spring:message code="newUnit" />', '#fm-goodsUnit', '<c:url value='/goodsUnit/addModel.html' />', newGoodsUnitCallback)" title="<spring:message code="newUnit" />"><spring:message code="newUnit" /></a> 
		<!--<a id="btn-editGoodsUnit" href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-edit" plain="true" onclick="editModel('#dg-goodsUnit', '#dlg-goodsUnit', '<spring:message code="editUnit" />', '#fm-goodsUnit', '<c:url value='/goodsUnit/updateModel.html' />', newGoodsUnitCallback)" title="<spring:message code="editUnit" />"></a> 
		<a href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-remove" plain="true" onclick="destroyMultipleModel('#dg-goodsUnit', '<spring:message code="goodsUnit" />', '<c:url value='/goodsUnit/deleteModels.html' />', function() {loadGridData ('#dg-goodsUnit', '<c:url value='/goodsUnit/getAllModel.html' />')})" title="<spring:message code="removeUnit" />"></a>-->
		<a href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-reload" plain="true" onclick="loadGridData ('#dg-goodsUnit', '<c:url value='/goodsUnit/getAllModel.html' />')" title="<spring:message code="refresh" />"><spring:message code="refresh" /></a>
	</div>

	<div id="dlg-goodsUnit" class="easyui-dialog"
		style="width: 400px; height: 300px; padding: 10px 20px" closed="true"
		buttons="#dlg-buttons-goodsUnit" data-options="modal:true">
		<div class="ftitle"><spring:message code="goodsUnit" /></div>
		<form id="fm-goodsUnit" class="fm" method="post" novalidate>
			<div class="fitem divHidden">
				<input name="id" id="goodsUnitId" value="0" />
			</div>
			<div class="fitem">
				<label><spring:message code="name" />:</label> 
				<input id="name" name="name" class="easyui-validatebox" required="true" 
				validType="myRemote['<c:url value='/goodsUnit/checkExist.html' />', 'name', '#goodsUnitId']" 
				onkeyup="if(event.keyCode == 13) {$('#save-goodsUnit').click()}" />
			</div>
		</form>
	</div>
	<div id="dlg-buttons-goodsUnit">
		<a id="save-goodsUnit-add" href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-ok" onclick="saveModel('#dg-goodsUnit', '#dlg-goodsUnit', '#fm-goodsUnit', function() {loadGridData ('#dg-goodsUnit', '<c:url value='/goodsUnit/getAllModel.html' />')}, null, false)"><spring:message code="continueAdd" /></a>
		<a id="save-goodsUnit" href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-ok" onclick="saveModel('#dg-goodsUnit', '#dlg-goodsUnit', '#fm-goodsUnit', function() {loadGridData ('#dg-goodsUnit', '<c:url value='/goodsUnit/getAllModel.html' />')})"><spring:message code="addAndClose" /></a> 
	</div>
